import java.util.Arrays;

public class MyStack {
    private int[] elem;
    private int UsedSide;
    public MyStack(){
        elem = new int[20];
    }
    public void push(int val){
        if(IsFull()){
            elem = Arrays.copyOf(elem,2*elem.length);
        }
        elem[UsedSide] = val;
        UsedSide++;
    }
    public int pop(){
        if(Isempty()){
            throw new EmptyStackException("栈为空了！");
        }
        UsedSide--;
        return elem[UsedSide];
    }
    public int top(){
        if(Isempty()){
            throw new EmptyStackException("栈为空了！");
        }
        return elem[UsedSide-1];
    }
    public int geisize(){
        return UsedSide;
    }
    public Boolean Isempty(){
        return UsedSide == 0;
    }
    public void Dispaly(){
        for (int i = 0; i < UsedSide; i++) {
            System.out.println(elem[i]);
        }
    }

    public Boolean IsFull(){
        return elem.length == UsedSide;
    }




}
